package com.gosophia.conference.action.summary;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.conferenceManagement.common.dto.DocumentDTO;
import com.gosophia.conferenceManagement.common.ws.ConferenceQueryWebService;
import com.gosophia.conferenceManagement.summary.dto.SummaryJobDataDTO;
import com.gosophia.conferenceManagement.summary.ws.SummaryWebService;

@Scope("prototype")
@Controller("DraftSummaryAutoSaveAction")
public class DraftSummaryAutoSaveAction extends BaseSupportAction{
    
    private static final long serialVersionUID = 1L;
    @Autowired
    private SummaryWebService summaryWebService;
    @Autowired
    private ConferenceQueryWebService  conferenceQueryWebService;
    
    //在线文档在仓库中的路径
    private String onlinePath;
    //在线文档版本
    private String onlineVersion;
    
    private List<Long> oldDocumentIds;
    
    private SummaryJobDataDTO summaryJobDataDTO;
    @Override
    @LogRecord(eventAction="会议管理-会议总结-总结起草自动保存",eventTarget="summaryJobDataDTO")
    public String _execute() throws Exception {
        List<DocumentDTO> oldDocumentList = new ArrayList<DocumentDTO>();
        //原来的附件
        if(oldDocumentIds!=null&&oldDocumentIds.size()!=0){
            for(Long id:oldDocumentIds){
                DocumentDTO d = conferenceQueryWebService.findDocumentByDocumentId(id);
                oldDocumentList.add(d);
            }
            
        }
        //在线文档
        DocumentDTO onlineDocument = new DocumentDTO();
        onlineDocument.setDocumentPath(onlinePath);
        onlineDocument.setDocumentVersion(onlineVersion);
        summaryJobDataDTO.setOnlineDocumentDTO(onlineDocument);
        
        summaryWebService.autoSaveSummaryJobData(summaryJobDataDTO);
        
        return SUCCESS;
    }
    public SummaryJobDataDTO getSummaryJobDataDTO() {
        return summaryJobDataDTO;
    }
    public void setSummaryJobDataDTO(SummaryJobDataDTO summaryJobDataDTO) {
        this.summaryJobDataDTO = summaryJobDataDTO;
    }
    public String getOnlinePath() {
        return onlinePath;
    }
    public void setOnlinePath(String onlinePath) {
        this.onlinePath = onlinePath;
    }
    public String getOnlineVersion() {
        return onlineVersion;
    }
    public void setOnlineVersion(String onlineVersion) {
        this.onlineVersion = onlineVersion;
    }
    public List<Long> getOldDocumentIds() {
        return oldDocumentIds;
    }
    public void setOldDocumentIds(List<Long> oldDocumentIds) {
        this.oldDocumentIds = oldDocumentIds;
    }
    
    
}
